package per.forest.database.meta;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.List;

public class Test {

	public static void main(String[] args) throws SQLException {
		Connection conn = null;
		try {
			Class.forName("com.mysql.jdbc.Driver");
			String url = "jdbc:mysql://127.0.0.1:3306/zhaoyinzi?useUnicode=true&characterEncoding=UTF-8";
			conn = DriverManager.getConnection(url, "root", "root");
			
			List<Table> tables = DBMetaTool.getTableByDataBase(conn, "ZHAOYINZI", DataBaseType.MYSQL);
			for (Table table : tables) {
				System.out.println(table.getName());
				for (Column column : table.getColumns()) {
					System.out.println("\t"+column.getName()+":"+column.getJavaType()+":"+column.getRemark());
				}
			}
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (conn != null) {
				conn.close();
			}
		}

	}

}
